﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Web.Routing;

namespace ICP.CustomRouting.Sample
{
    public class RouteConfig
    {
        public static void RegisterRoutes(RouteCollection routes)
        {
            routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
            routes.IgnoreRoute("Content/{*pathInfo}");
            routes.IgnoreRoute("bundles/{*pathInfo}");             

            routes.MapRoute(
                name: "Test",
                url: "Test/{Country}/{Maker}/{Type}",
                defaults: new { controller = "Test", action = "Index", Country = UrlParameter.Optional, Maker = UrlParameter.Optional, Type = UrlParameter.Optional },
                lookupParameters: new string[] { "Country", "Maker", "Type" },
                lookupService: new LookupService());

            var defaultRoute = routes.MapReplaceableRoute(
                  name: "Default",
                  url: "{controller}/{action}/{id}",
                  defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }
              );

            var route = routes.MapRoute(
                name: "Dynamic",
                url: "{*name}",
                defaults: new { controller = "Dynamic", action = "Index" });
            
            defaultRoute.AlternativeRoute = route;
        }
    }
}